package cn.ycc1.mymiddle.chat;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ycc
 * @date 2025/5/1
 */
@RestController
public class ChatController {

//    @Autowired
//    ChatModel myChatModel;

//    ChatClient.Builder builder = ChatClient.builder(myChatModel);
    // or create a ChatClient with the default builder settings:
//    ChatClient chatClient = ChatClient.create(myChatModel);

    private final ChatClient chatClient;
    public ChatController(ChatClient.Builder builder) {
        this.chatClient = builder.build();
    }

    @GetMapping("/chat")
    public String chat(String input) {
        return this.chatClient.prompt()
                .user(input)
                .call()
                .content();
    }
}
